<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">

    <title>会员注册页面</title>
    <!-- 静态包含头信息!-->
    <%@include file="/pages/common/hand.jsp" %>

    <style type="text/css">
        .login_form {
            height: 420px;
            margin-top: 25px;
        }

    </style>
    <script type="text/javascript" src="static/jquery-1.7.2.min.js"></script>
    <script>
        $(function () {

            $("#code1").click(function () {

                this.src="<%=basePath%>Kaptcha.jpg?d="+new Date();
            })
            $("#sub_btn").click(function () {

                var username = $("#username").val();
                var password = $("#password").val();
                var repwd = $("#repwd").val();
                var email = $("#email").val();
                var coed = $.trim($("#code").val());
                code
                var usernamePutt = /^[a-z0-9_-]{3,16}$/
                var passwordPutt = /^[a-z0-9_-]{6,18}$/;
                var emailPutt = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
                var $errormas = $("span.errorMsg");
                if (!usernamePutt.test(username)) {
                    $errormas.text("用户名格式错误");
                    return false;
                } else if (!passwordPutt.test(password)) {
                    $errormas.text("密码格式错误");
                    return false;
                } else if (password != repwd) {
                    $errormas.text("两次密码输入不一致");
                    return false;
                } else if (!emailPutt.test(email)) {
                    $errormas.text("邮箱格式错误");
                    return false;
                } else if (coed == "") {
                    $errormas.text("验证码不能为空");
                    return false;
                } else {
                    $errormas.text("");
                    return true;
                }


            });
        });
    </script>
</head>


<body>
<div id="login_header">
    <img class="logo_img" alt="" src="static/img/logo.jpg">
</div>

<div class="login_banner">

    <div id="l_content">
        <span class="login_word">欢迎注册</span>
    </div>

    <div id="content">
        <div class="login_form">
            <div class="login_box">
                <div class="tit">
                    <h1>注册会员</h1>
                    <span class="errorMsg">
                        <%--使用EL表达式错误信息回显,访问页面时若没有错误信息则显示空串--%>
                        ${empty requestScope.errorMas?"":requestScope.errorMas}
                    </span>

                </div>
                <div class="form">
                    <form action="/project/UserServlet" method="post">
                        <input type="hidden" name="type" value="regist">
                        <label>用户名称：</label>
                        <input class="itxt" type="text" placeholder="请输入用户名" autocomplete="off" tabindex="1"
                               name="username" id="username"
                               value=${empty requestScope.userNameBack?"":requestScope.userNameBack}>
                        <br/>
                        <br/>
                        <label>用户密码：</label>
                        <input class="itxt" type="password" placeholder="请输入密码" autocomplete="off" tabindex="1"
                               name="password" id="password"/>
                        <br/>
                        <br/>
                        <label>确认密码：</label>
                        <input class="itxt" type="password" placeholder="确认密码" autocomplete="off" tabindex="1"
                               name="repwd" id="repwd"/>
                        <br/>
                        <br/>
                        <label>电子邮件：</label>
                        <input class="itxt" type="text" placeholder="请输入邮箱地址" autocomplete="off" tabindex="1"
                               name="email" id="email"
                               value=${empty requestScope.emaliBack?"":requestScope.emaliBack}>
                        <br/>
                        <br/>
                        <label>验证码：</label>
                        <input class="itxt" type="text" style="width: 150px;" id="code" name="code"/>
                        <img alt="" src="Kaptcha.jpg" style="float: right; margin-right: 40px;width: 90px;height: 40px" id="code1">
                        <br/>
                        <br/>
                        <input type="submit" value="注册" id="sub_btn"/>

                    </form>
                </div>

            </div>
        </div>
    </div>
</div>
<%@include file="/pages/common/footer.jsp" %>
</body>
</html>